package com.fingard.dsp.bank.directbank.hxb01;

import java.math.BigDecimal;
import java.sql.Connection;
import java.text.MessageFormat;
import java.util.Date;
import java.util.Map;
import java.util.UUID;

import com.fingard.FGBiz;
import com.fingard.constant.Format;
import com.fingard.db.JDBCHelper;
import com.fingard.dsp.bank.directbank.bankInterface.IElecBillTrans;
import com.fingard.dsp.bank.directbank.fngrd01.util.StringHelper;
import com.fingard.dsp.bank.reqrespobj.elecbilltrans.*;
import com.fingard.dsp.bank.reqrespobj.elecbilltrans.detail.*;

/**
 * 华夏银行电票操作类
 * Created by F on 2018/12/21.
 */
public class HXB01ElecBillTrans extends HXB01Base implements IElecBillTrans {

    private static final String INSERTSEQ = "INSERT INTO REQSEQIDMAPPING(URID,BANKCODE,TRANSDATE,REQSEQID,BANKREQSEQID) values (?,?,?,?,?);";
    private static final String SELECTSEQ = "SELECT BANKREQSEQID FROM REQSEQIDMAPPING WHERE REQSEQID=?;";

    /**
     * 通用签收 b2e0109 已测
     */
    @Override
    public RetAtsB003BillRespSubmit D_B003_BillResp_Submit(ReqB003BillRespSubmit query) throws Exception{
        RetAtsB003BillRespSubmit retAts=new RetAtsB003BillRespSubmit(query.reqHeader);
        RetAtsB003BillRespSubmitDetail detail=new RetAtsB003BillRespSubmitDetail();
        retAts.writeBeforeDetail();
        Connection conn= FGBiz.getLocalDbConn();
        while(query.readRecord()){
            try {
                StringBuilder stringBuilder = new StringBuilder();
                for (int i = 0; i < 13; i++) {
                    stringBuilder.append("{" + i + "}#");
                }
                stringBuilder.append("@@@@");
                String[] body = new String[13];
                body[0] = "B309003";//交易代码
                //票据信息
                body[1] = query.detail.billNo;//电子票据号码
                String bankSeqId = getQryTransID2();
                body[2] = bankSeqId;//业务参考号
                String uuid = UUID.randomUUID().toString().replaceAll("-", "");
                JDBCHelper.update(conn, INSERTSEQ, new Object[]{uuid, query.reqHeader.bankCode, Format.Date8Format.format(new Date()), query.detail.reqSeqID, bankSeqId});
                body[3] = "";//网银客户号
                body[4] = "";//电子签名
                body[5] = query.detail.actNum;//账号
                //查询背书转让标识和票据状态
                String[] status=new String[2];
                for(int i=0;i<4;i++){
                    status=getBillStatus(query.detail.billNo,getBankConfig().getMapKeyByValue("billTypeMapping",query.detail.billType),query.detail.actNum,i+"");
                    if(com.fingard.text.StringHelper.hasAnyChar(status[0])){
                        break;
                    }
                }
                if(com.fingard.text.StringHelper.hasAnyChar(status[0])){
                    body[6] = status[1];//票据状态???
                    body[7] = query.detail.memo;//备注
                    //回复信息
                    body[8] = "1".equals(query.detail.respFlag) ? "SU00" : "SU01";//回复标记
                    if("6".equals(query.detail.respType) && "2".equals(query.detail.respFlag)){
                        if (query.detail.unPayCode.equals("99")) {
                            body[9]="DC09";//拒付代码
                        } else if (Integer.parseInt(query.detail.unPayCode) > 0 && Integer.parseInt(query.detail.unPayCode) <= 9) {
                            int unPayCode = Integer.parseInt(query.detail.unPayCode);
                            body[9]="DC0" + (unPayCode - 1);
                        } else {
                            detail.respCode = "-1";
                            detail.respInfo = "拒付理由代码错误";
                            WriteBankLogLn("拒付理由代码错误");
                            retAts.writeDetail(detail);
                            retAts.writeEnd();
                            return retAts;
                        }
                    }else {
                        body[9] = query.detail.protocolNo;//承兑协议号/贴现协议号
                    }
                    body[10] = query.detail.unPayMemo;//拒付备注
                    body[11] = "";///备注1
                    body[12] = "";//备注2
                    //赋值通用参数
                    StringBuilder stringBuilder1 = new StringBuilder();
                    for (int i = 0; i < body.length; i++) {
                        stringBuilder1.append(body[i]).append(",");
                    }
                    String sendInfo = MessageFormat.format(stringBuilder.toString(), body[0], body[1],body[2], body[3], body[4], body[5]
                            , body[6], body[7], body[8], body[9], body[10], body[11], body[12]);
                    //请求银行
                    String[] tmpStrRet = sendToBank(sendInfo);
                    if (tmpStrRet[0].length() == 0) {
                        //返回码
                        String[] resultArr = tmpStrRet[1].trim().replaceAll("@", "").replaceAll("\r", "")
                                .replaceAll("\n", "").split("#");
                        //接收响应参数
                        if (!StringHelper.isNullOrEmpty(resultArr[0])) {
                            detail.respCode = "0";
                            detail.respInfo = "";
                            detail.reqSeqID = query.detail.reqSeqID;
                            if("000000".equals(resultArr[0].trim()) || "111111".equals(resultArr[0].trim()) || "EL6001".equals(resultArr[0].trim())){
                                detail.transState = resultArr[0];
                            }else {
                                detail.transState = "others";
                            }
                            detail.payInfoCode = detail.transState;
                        }else {
                            detail.respCode = "-1";
                            detail.respInfo = "银行返回的数据格式不符合预期";
                        }
                    } else {
                        detail.respCode = "-1";
                        detail.respInfo = tmpStrRet[1].toString();
                    }
                }else {
                    detail.respCode = "-1";
                    detail.respInfo ="查询票据状态或背书转让标识异常";
                }
            }catch(Exception e){
                detail.respCode = "-1";
                detail.respInfo = e.getMessage();
                e.printStackTrace();
                WriteBankLogLn("票据"+query.detail.billNo+"签收异常");
            }finally {
                conn.close();
            }
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 出票 b2e0101 已测
     */
    @Override
    public RetAtsB101BillApplySubmit D_B101_BillResp_Submit(ReqB101BillApplySubmit query) throws Exception{
        RetAtsB101BillApplySubmit retAts=new RetAtsB101BillApplySubmit(query.reqHeader);
        RetAtsB101BillApplySubmitDetail detail=new RetAtsB101BillApplySubmitDetail();
        retAts.writeBeforeDetail();
        Connection conn= FGBiz.getLocalDbConn();
        while(query.readRecord()){
            try{
                StringBuilder stringBuilder=new StringBuilder();
                for(int i=0;i<38;i++){
                    stringBuilder.append("{"+i+"}#");
                }
                stringBuilder.append("@@@@");
                String[] body=new String[38];
                body[0]="B301001";//交易代码
                String bankSeqId=getQryTransID2();
                body[1]=bankSeqId;//批次号
                body[2]=bankSeqId;//业务参考号
                //记录ats支付流水号对应的银行支付流水号，供查询状态接口使用
                String uuid = UUID.randomUUID().toString().replaceAll("-", "");
                JDBCHelper.update(conn, INSERTSEQ, new Object[]{uuid, query.reqHeader.bankCode, Format.Date8Format.format(new Date()), query.detail.reqSeqID, bankSeqId});

                body[3]=getBankConfig().getMapValueByKey("billTypeMapping",query.detail.billType);//票据种类 AC01：我行银承 AC02：商承 AC09：他行
                body[4]=query.detail.autoPromptReceipt;//是否自动发起提示收票
                body[5]=query.detail.billAmt;//票据金额
                body[6]=query.detail.issDate.substring(0,10);//出票日期
                body[7]=query.detail.dueDate.substring(0,10);//到期日
                body[8]=getBankConfig().getMapValueByKey("transFlagMapping",query.detail.transFlag);//不得转让标记
                body[9]=bankFront.corpNo;//出票人客户号
                body[10]=query.detail.drawName;//出票人名称
                body[11]=query.detail.drawAct;//出票人账号
                body[12]=bankFront.org;//组织机构号
                body[13]=query.detail.accpName;//承兑人名称
                body[14]=query.detail.accpAct;//承兑人账号
                body[15]=query.detail.accpBnkCode;//承兑人开户行行号
                body[16]=query.detail.payeeName;//收款人名称
                body[17]=query.detail.payeeAct;//收款人账号
                body[18]=query.detail.payeeBnkCode;//收款人开户行行号
                body[19]=query.detail.contractNo;//贸易合同号
                body[20]=query.detail.billAmt;//贸易合同金额
                body[21]="002";//担保方式 001：电票 002：保证金 003：信用 004：质押
                body[22]="1";//总笔数
                body[23]=query.detail.billAmt;//总金额
                body[24]=query.detail.autoPromptReceipt;//是否全部自动发起提示收票
                body[25]="001";//保证金账号类别 “001活期”或“002定期”
                //保证金=票据金额-占用授信额度
                //保证金比率(%)=保证金*100/票据金额
                String bailRate=(new BigDecimal(query.detail.billAmt).subtract(new BigDecimal(query.detail.useCreditAmount)))
                        .multiply(new BigDecimal("100")).divide(new BigDecimal(query.detail.billAmt),2,BigDecimal.ROUND_HALF_UP).toString();
                body[26]=bailRate;//保证金比例
                body[27]="CNY";//币种
                body[28]=query.detail.drawAct;//结算帐号
                body[29]="";//组织机构代码证代码
                body[30]=query.detail.drawAct;//收息帐号
                body[31]="1";//是否保兑仓 0：是  1：否
                body[32]="";//开户许可证号
                body[33]="";//保证金账户
                body[34]="";//输入时间
                body[35]="";//电子签名
                body[36]="";///备注1
                body[37]="";//备注2
                //赋值通用参数
                StringBuilder stringBuilder1=new StringBuilder();
                for(int i=0;i<body.length;i++){
                    stringBuilder1.append(body[i]).append(",");
                }
                String sendInfo = MessageFormat.format(stringBuilder.toString(),body[0],body[1],body[2],body[3],body[4],body[5],body[6],body[7],body[8],
                        body[9],body[10],body[11],body[12],body[13],body[14],body[15],body[16],body[17],body[18],body[19],body[20],body[21],body[22],
                        body[23],body[24],body[25],body[26],body[27],body[28],body[29],body[30],body[31],body[32],body[33],body[34],body[35],body[36],body[37]);

                //请求银行
                String[] tmpStrRet = sendToBank(sendInfo);
                if (tmpStrRet[0].length() == 0) {
                    //返回码
                    String[] resultArr = tmpStrRet[1].trim().replaceAll("@","").replaceAll("\r","")
                            .replaceAll("\n","").split("#");
                    //接收响应参数
                    if("000000".equals(resultArr[0].trim())){
                        detail.respCode = "0";
                        detail.respInfo = "";
                        detail.reqSeqID = query.detail.reqSeqID;
                        detail.payInfoCode = resultArr[0];
                        detail.transState = detail.payInfoCode;
                    }else {
                        detail.respCode = "0";
                        detail.respInfo = "";
                        detail.reqSeqID = query.detail.reqSeqID;
                        if("111111".equals(resultArr[0]) || "EL6001".equals(resultArr[0])){
                            detail.transState = resultArr[0];
                        }else {
                            detail.transState = "others";
                        }
                        detail.payInfoCode = detail.transState;
                    }
                }else {
                    detail.respCode = "-1";
                    detail.respInfo = tmpStrRet[1].toString();
                }
            }catch(Exception e){
                e.printStackTrace();
                WriteBankLogLn("出票人"+query.detail.drawName+"出票异常");
            }finally {
                conn.close();
            }
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
    * 提示承兑 b2e0105  已测
    * 银行承兑 华夏银行系统自动承兑
     * * */
    @Override
    public RetAtsB102BillAccpSubmit D_B102_BillResp_Submit(ReqB102BillAccpSubmit query) throws Exception{
        RetAtsB102BillAccpSubmit retAts=new RetAtsB102BillAccpSubmit(query.reqHeader);
        RetAtsB102BillAccpSubmitDetail detail=new RetAtsB102BillAccpSubmitDetail();
        retAts.writeBeforeDetail();
        Connection conn= FGBiz.getLocalDbConn();
        while(query.readRecord()){
            try{
                StringBuilder stringBuilder=new StringBuilder();
                for(int i=0;i<5;i++){
                    stringBuilder.append("{"+i+"}#");
                }
                stringBuilder.append("@@@@");
                String[] body=new String[5];
                body[0]="B308003";//交易代码
                body[1]=query.detail.billNo;//电子票据号码
                String bankSeqId=getQryTransID2();
                body[2]=bankSeqId;//业务参考号
                //记录ats支付流水号对应的银行支付流水号，供查询状态接口使用
                String uuid = UUID.randomUUID().toString().replaceAll("-", "");
                JDBCHelper.update(conn, INSERTSEQ, new Object[]{uuid, query.reqHeader.bankCode, Format.Date8Format.format(new Date()), query.detail.reqSeqID, bankSeqId});
                body[3]=query.detail.billAmt;//票据金额
                body[4]=query.detail.actNum;//出票人账号
                //赋值通用参数
                StringBuilder stringBuilder1=new StringBuilder();
                for(int i=0;i<body.length;i++){
                    stringBuilder1.append(body[i]).append(",");
                }
                String sendInfo = MessageFormat.format(stringBuilder.toString(),body[0],body[1],body[2],body[3],body[4]);
                //请求银行
                String[] tmpStrRet = sendToBank(sendInfo);
                if (tmpStrRet[0].length() == 0) {
                    //返回码
                    String[] resultArr = tmpStrRet[1].trim().replaceAll("@","").replaceAll("\r","")
                            .replaceAll("\n","").split("#");
                    if (!StringHelper.isNullOrEmpty(resultArr[0])) {
                        detail.respCode = "0";
                        detail.respInfo = "";
                        detail.reqSeqID = query.detail.reqSeqID;
                        if("000000".equals(resultArr[0].trim()) || "111111".equals(resultArr[0].trim()) || "EL6001".equals(resultArr[0].trim())){
                            detail.transState = resultArr[0];
                        }else {
                            detail.transState = "others";
                        }
                        detail.payInfoCode = detail.transState;
                    }else {
                        detail.respCode = "-1";
                        detail.respInfo = "银行返回的数据格式不符合预期";
                    }
                }else {
                    detail.respCode = "-1";
                    detail.respInfo = tmpStrRet[1].toString();
                }
            }catch(Exception e){
                e.printStackTrace();
                WriteBankLogLn("票据"+query.detail.billNo+"提示承兑异常");
            }finally {
                conn.close();
            }
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 撤票 b2e0104 已测
     */
    @Override
    public RetAtsB103BillRetSubmit D_B103_BillResp_Submit(ReqB103BillRetSubmit query) throws Exception{
        RetAtsB103BillRetSubmit retAts=new RetAtsB103BillRetSubmit(query.reqHeader);
        RetAtsB103BillRetSubmitDetail detail=new RetAtsB103BillRetSubmitDetail();
        retAts.writeBeforeDetail();
        Connection conn= FGBiz.getLocalDbConn();
        while(query.readRecord()){
            try{
                StringBuilder stringBuilder=new StringBuilder();
                for(int i=0;i<5;i++){
                    stringBuilder.append("{"+i+"}#");
                }
                stringBuilder.append("@@@@");
                String[] body=new String[5];
                body[0]="B301010";//交易代码
                body[1]=query.detail.billNo;//电子票据号码
                String seqNo="";//原申请业务参考号
                Map<String, Object> selMap= JDBCHelper.execQuerySingle(conn,SELECTSEQ,new Object[]{query.detail.oldSeq});
                if(selMap.size()>0){
                    seqNo=selMap.get("BANKREQSEQID").toString();
                }else {
                    retAts.writeRespCode("-1");
                    retAts.writeRespInfo("业务流水号关联异常");
                    retAts.writeEnd();
                    return retAts;
                }
                body[2]=seqNo;//原申请业务参考号
                String bankSeqId=getQryTransID2();
                body[3]=bankSeqId;//业务参考号
                String uuid = UUID.randomUUID().toString().replaceAll("-", "");
                JDBCHelper.update(conn, INSERTSEQ, new Object[]{uuid, query.reqHeader.bankCode, Format.Date8Format.format(new Date()), query.detail.reqSeqID, bankSeqId});
                body[4]=query.detail.actNum;//出票人账号
                //赋值通用参数
                StringBuilder stringBuilder1=new StringBuilder();
                for(int i=0;i<body.length;i++){
                    stringBuilder1.append(body[i]).append(",");
                }
                String sendInfo = MessageFormat.format(stringBuilder.toString(),body[0],body[1],body[2],body[3],body[4]);
                //请求银行
                String[] tmpStrRet = sendToBank(sendInfo);
                if (tmpStrRet[0].length() == 0) {
                    //返回码
                    String[] resultArr = tmpStrRet[1].trim().replaceAll("@","").replaceAll("\r","")
                            .replaceAll("\n","").split("#");
                    if (!StringHelper.isNullOrEmpty(resultArr[0])) {
                        detail.respCode = "0";
                        detail.respInfo = "";
                        detail.reqSeqID = query.detail.reqSeqID;
                        if("000000".equals(resultArr[0].trim()) || "111111".equals(resultArr[0].trim()) || "EL6001".equals(resultArr[0].trim())){
                            detail.payInfoCode = resultArr[0];
                        }else {
                            detail.payInfoCode = "others";
                        }
                        detail.transState = detail.payInfoCode;
                    }else {
                        detail.respCode = "-1";
                        detail.respInfo = "银行返回的数据格式不符合预期";
                    }
                }else {
                    detail.respCode = "-1";
                    detail.respInfo = tmpStrRet[1].toString();
                }
            }catch(Exception e){
                e.printStackTrace();
                WriteBankLogLn("票据"+query.detail.billNo+"撤票异常");
            }finally {
                conn.close();
            }
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 提示收票 b2e0108 已测
     */
    @Override
    public RetAtsB104BillReceSubmit D_B104_BillResp_Submit(ReqB104BillReceSubmit query) throws Exception{
        RetAtsB104BillReceSubmit retAts=new RetAtsB104BillReceSubmit(query.reqHeader);
        RetAtsB104BillReceSubmitDetail detail=new RetAtsB104BillReceSubmitDetail();
        retAts.writeBeforeDetail();
        Connection conn= FGBiz.getLocalDbConn();
        while(query.readRecord()){
            try{
                StringBuilder stringBuilder=new StringBuilder();
                for(int i=0;i<20;i++){
                    stringBuilder.append("{"+i+"}#");
                }
                stringBuilder.append("@@@@");
                String[] body=new String[20];
                body[0]="B308011";//交易代码
                body[1]="1";//批次号
                body[2]=query.detail.billNo;//电子票据号码
                String bankSeqId=getQryTransID2();
                body[3]=bankSeqId;//业务参考号
                String uuid = UUID.randomUUID().toString().replaceAll("-", "");
                JDBCHelper.update(conn, INSERTSEQ, new Object[]{uuid, query.reqHeader.bankCode, Format.Date8Format.format(new Date()), query.detail.reqSeqID, bankSeqId});
                body[4]=getBankConfig().getMapValueByKey("billTypeMapping",query.detail.billType);//票据种类
                body[5]=query.detail.billAmt.contains(".")?query.detail.billAmt:query.detail.billAmt+".00";//票据金额
                body[6]=Format.Date10Format.format(Format.Date10Format.parse(query.detail.issDate));//出票日期
                body[7]=Format.Date10Format.format(Format.Date10Format.parse(query.detail.dueDate));//到期日
                body[8]=bankFront.corpNo;//出票人客户号
                body[9]=query.detail.billOpenName;//出票人名称
                body[10]=query.detail.billOpenAcc;//出票人账号
                body[11]="";//组织机构号
                body[12]="";//承兑人名称
                body[13]="";//承兑人账号
                body[14]="";//承兑人开户行行号
                body[15]=query.detail.payeeName;//收款人名称
                body[16]=query.detail.payeeAct;//收款人账号
                body[17]=query.detail.payeeBnkCode;//收款人开户行行号
                body[18]="1";//总笔数
                body[19]=query.detail.billAmt.contains(".")?query.detail.billAmt:query.detail.billAmt+".00";//总金额
                //赋值通用参数
                StringBuilder stringBuilder1=new StringBuilder();
                for(int i=0;i<body.length;i++){
                    stringBuilder1.append(body[i]).append(",");
                }
                String sendInfo = MessageFormat.format(stringBuilder.toString(),body[0],body[1],body[2],body[3],body[4],body[5],body[6],body[7],
                        body[8],body[9],body[10],body[11],body[12],body[13],body[14],body[15],body[16],body[17],body[18],body[19]);
                //请求银行
                String[] tmpStrRet = sendToBank(sendInfo);
                if (tmpStrRet[0].length() == 0) {
                    //返回码
                    String[] resultArr = tmpStrRet[1].trim().replaceAll("@","").replaceAll("\r","")
                            .replaceAll("\n","").split("#");
                    if (!StringHelper.isNullOrEmpty(resultArr[0])) {
                        detail.respCode = "0";
                        detail.respInfo = "";
                        detail.reqSeqID = query.detail.reqSeqID;
                        if("000000".equals(resultArr[0].trim()) || "111111".equals(resultArr[0].trim()) || "EL6001".equals(resultArr[0].trim())){
                            detail.payInfoCode = resultArr[0];
                        }else {
                            detail.payInfoCode = "others";
                        }
                        detail.transState = detail.payInfoCode;
                    }else {
                        detail.respCode = "-1";
                        detail.respInfo = "银行返回的数据格式不符合预期";
                    }
                }else {
                    detail.respCode = "-1";
                    detail.respInfo = tmpStrRet[1].toString();
                }
            }catch(Exception e){
                e.printStackTrace();
                WriteBankLogLn("票据"+query.detail.billNo+"提示收票异常");
            }finally {
                conn.close();
            }
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 背书转让申请 b2e0280 已测
     */
    @Override
    public RetAtsB105BillEndoSubmit D_B105_BillResp_Submit(ReqB105BillEndoSubmit query) throws Exception{
        RetAtsB105BillEndoSubmit retAts=new RetAtsB105BillEndoSubmit(query.reqHeader);
        RetAtsB105BillEndoSubmitDetail detail=new RetAtsB105BillEndoSubmitDetail();
        retAts.writeBeforeDetail();
        Connection conn= FGBiz.getLocalDbConn();
        while(query.readRecord()){
            try{
                StringBuilder stringBuilder=new StringBuilder();
                for(int i=0;i<10;i++){
                    stringBuilder.append("{"+i+"}#");
                }
                stringBuilder.append("@@@@");
                String[] body=new String[10];
                body[0]="B302001";//交易代码
                body[1]=query.detail.billNo;//电子票据号码
                String bankSeqId=getQryTransID2();
                body[2]=bankSeqId;//业务参考号
                String uuid = UUID.randomUUID().toString().replaceAll("-", "");
                JDBCHelper.update(conn, INSERTSEQ, new Object[]{uuid, query.reqHeader.bankCode, Format.Date8Format.format(new Date()), query.detail.reqSeqID, bankSeqId});
                body[3]=getBankConfig().getMapValueByKey("transFlagMapping",query.detail.transFlag);//转让标志
                body[4]="";//背书人网银客户号
                body[5]="";//背书人电子签名
                body[6]=query.detail.actNum;//背书人账号
                body[7]=query.detail.receName;//被背书人名称
                body[8]=query.detail.receAct;//被背书人账号
                body[9]=query.detail.receBnkCode;//被背书人开户行行号
                //赋值通用参数
                StringBuilder stringBuilder1=new StringBuilder();
                for(int i=0;i<body.length;i++){
                    stringBuilder1.append(body[i]).append(",");
                }
                String sendInfo = MessageFormat.format(stringBuilder.toString(),body[0],body[1],body[2],body[3],body[4],body[5],body[6],body[7],body[8],body[9]);
                //请求银行
                String[] tmpStrRet = sendToBank(sendInfo);
                if (tmpStrRet[0].length() == 0) {
                    //返回码
                    String[] resultArr = tmpStrRet[1].trim().replaceAll("@","").replaceAll("\r","")
                            .replaceAll("\n","").split("#");
                    if (!StringHelper.isNullOrEmpty(resultArr[0])) {
                        detail.respCode = "0";
                        detail.respInfo = "";
                        detail.reqSeqID = query.detail.reqSeqID;
                        if("000000".equals(resultArr[0].trim()) || "111111".equals(resultArr[0].trim()) || "EL6001".equals(resultArr[0].trim())){
                            detail.payInfoCode = resultArr[0];
                        }else {
                            detail.payInfoCode = "others";
                        }
                        detail.transState = detail.payInfoCode;
                    }else {
                        detail.respCode = "-1";
                        detail.respInfo = "银行返回的数据格式不符合预期";
                    }
                }else {
                    detail.respCode = "-1";
                    detail.respInfo = tmpStrRet[1].toString();
                }
            }catch(Exception e){
                e.printStackTrace();
                WriteBankLogLn("票据"+query.detail.billNo+"背书转让异常");
            }finally {
                conn.close();
            }
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 贴现申请 b2e0110 已测
     */
    @Override
    public RetAtsB106BillDiscSubmit D_B106_BillResp_Submit(ReqB106BillDiscSubmit query) throws Exception{
        RetAtsB106BillDiscSubmit retAts=new RetAtsB106BillDiscSubmit(query.reqHeader);
        RetAtsB106BillDiscSubmitDetail detail=new RetAtsB106BillDiscSubmitDetail();
        retAts.writeBeforeDetail();
        Connection conn= FGBiz.getLocalDbConn();
        while(query.readRecord()){
            try{
                StringBuilder stringBuilder=new StringBuilder();
                for(int i=0;i<29;i++){
                    stringBuilder.append("{"+i+"}#");
                }
                stringBuilder.append("@@@@");
                String[] body=new String[29];
                body[0]="B303001";//交易代码
                body[1]=query.detail.billNo;//电子票据号码
                String bankSeqId=getQryTransID2();
                body[2]=bankSeqId;//业务参考号
                body[3]=bankSeqId;//批次号
                String uuid = UUID.randomUUID().toString().replaceAll("-", "");
                JDBCHelper.update(conn, INSERTSEQ, new Object[]{uuid, query.reqHeader.bankCode, Format.Date8Format.format(new Date()), query.detail.reqSeqID, bankSeqId});
                //贴现信息
                body[4]="1".equals(query.detail.discType)?"RM00":"RM01";//贴现种类
                body[5]= Format.Date10Format.format(new Date());//贴现申请日期[贴现日]
                body[6]=query.detail.discRate;//贴现利率
                body[7]="";//贴现实付金额[由网银自动计算，但客户可以修改]
                body[8]=getBankConfig().getMapValueByKey("transFlagMapping",query.detail.transFlag);//不得转让标记
                body[9]="1".equals(query.detail.payType)?"SM00":"SM01";//线上清算标记[客户勾选]
                body[10]=query.detail.repOpenDate;//贴现赎回开放日
                body[11]=query.detail.repDueDate;//贴现赎回截止日
                if("2".equals(query.detail.discType)){
                    body[12]=query.detail.repRate;//贴现赎回利率
                    body[13]=query.detail.repAmt.contains(".")?query.detail.repAmt:query.detail.repAmt+".00";//贴现赎回金额
                }else {
                    body[12]="";
                    body[13]="";
                }
                body[14]=query.detail.contractNo;//交易合同编号
                body[15]=query.detail.invoiceNo;//发票号码
                //入账信息
                body[16]=query.detail.actedAct;//帐号
                body[17]=query.detail.actedBnkCode;//行号
                //贴现申请人
                body[18]="";//网银客户号
                body[19]="";//电子签名
                body[20]=query.detail.actNum;//帐号 2019-01-24 ats传值为非申请人
                body[21]=getBankConfig().getMapValueByKey("payInterestType",query.detail.payInterestType);//付息方式[由客户自己选择：协议方式，买方方式，卖方方式]
                body[22]="";//付息账号
                //贴入人信息
                body[23]=query.detail.receName;//名称
                body[24]=query.detail.receAct;//账号
                body[25]=query.detail.receBnkCode;//开户行行号
                body[26]=query.detail.memo;//备注
                if ("3".equals(getBankConfig().getMapValueByKey("payInterestType", query.detail.payInterestType))) {
                    body[27]="100%";//付息比例
                }else{
                    body[27]="";//付息比例
                }
                body[28]=query.detail.discName;//付息账户名称
                //多笔参数拼接
                String sendInfo = MessageFormat.format(stringBuilder.toString(),body[0],body[1],body[2],body[3],body[4],body[5],body[6],body[7],body[8],
                        body[9],body[10],body[11],body[12],body[13],body[14],body[15],body[16],body[17],body[18],body[19],body[20],body[21],body[22],
                        body[23],body[24],body[25],body[26],body[27],body[28]);
                //请求银行
                String[] tmpStrRet = sendToBank(sendInfo);
                if (tmpStrRet[0].length() == 0) {
                    //返回码
                    String[] resultArr = tmpStrRet[1].trim().replaceAll("@","").replaceAll("\r","")
                            .replaceAll("\n","").split("#");
                    if (!StringHelper.isNullOrEmpty(resultArr[0])) {
                        detail.respCode = "0";
                        detail.respInfo = "";
                        detail.reqSeqID = query.detail.reqSeqID;
                        if("000000".equals(resultArr[0].trim()) || "111111".equals(resultArr[0].trim()) || "EL6001".equals(resultArr[0].trim())){
                            detail.payInfoCode = resultArr[0];
                        }else {
                            detail.payInfoCode = "others";
                        }
                        detail.transState = detail.payInfoCode;
                    }else {
                        detail.respCode = "-1";
                        detail.respInfo = "银行返回的数据格式不符合预期";
                    }
                }else {
                    detail.respCode = "-1";
                    detail.respInfo = tmpStrRet[1].toString();
                }
            }catch(Exception e){
                e.printStackTrace();
                WriteBankLogLn("票据"+query.detail.billNo+"贴现申请异常");
            }finally {
                conn.close();
            }
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 质押申请 b2e0285 已测

     */
    @Override
    public RetAtsB107BillPledSubmit D_B107_BillResp_Submit(ReqB107BillPledSubmit query) throws Exception{
        RetAtsB107BillPledSubmit retAts=new RetAtsB107BillPledSubmit(query.reqHeader);
        RetAtsB107BillPledSubmitDetail detail=new RetAtsB107BillPledSubmitDetail();
        retAts.writeBeforeDetail();
        Connection conn= FGBiz.getLocalDbConn();
        while(query.readRecord()){
            try{
                StringBuilder stringBuilder=new StringBuilder();
                for(int i=0;i<11;i++){
                    stringBuilder.append("{"+i+"}#");
                }
                stringBuilder.append("@@@@");
                String[] body=new String[11];
                body[0]="B304001";//交易代码
                //票据信息
                body[1]=query.detail.billNo;//电子票据号码
                String bankSeqId=getQryTransID2();
                body[2]=bankSeqId;//业务参考号
                String uuid = UUID.randomUUID().toString().replaceAll("-", "");
                JDBCHelper.update(conn, INSERTSEQ, new Object[]{uuid, query.reqHeader.bankCode, Format.Date8Format.format(new Date()), query.detail.reqSeqID, bankSeqId});
                //质押信息
                body[3]= com.fingard.constant.Format.Date10Format.format(new Date());//质押申请日期
                //出质人信息
                body[4]=bankFront.corpNo;//网银客户号
                body[5]="";//电子签名
                body[6]=query.detail.actNum;//账号
                //质权人信息
                body[7]=query.detail.receName;//名称
                body[8]=query.detail.receAct;//账号
                body[9]=query.detail.receBnkCode;//开户行行号
                body[10]=query.detail.memo;//备注
                String sendInfo = MessageFormat.format(stringBuilder.toString(),body[0],body[1],body[2],body[3],body[4],body[5],
                        body[6],body[7],body[8],body[9],body[10]);
                //请求银行
                String[] tmpStrRet = sendToBank(sendInfo);
                if (tmpStrRet[0].length() == 0) {
                    //返回码
                    String[] resultArr = tmpStrRet[1].trim().replaceAll("@","").replaceAll("\r","")
                            .replaceAll("\n","").split("#");
                    if (!StringHelper.isNullOrEmpty(resultArr[0])) {
                        detail.respCode = "0";
                        detail.respInfo = "";
                        detail.reqSeqID = query.detail.reqSeqID;
                        if("000000".equals(resultArr[0].trim()) || "111111".equals(resultArr[0].trim()) || "EL6001".equals(resultArr[0].trim())){
                            detail.payInfoCode = resultArr[0];
                        }else {
                            detail.payInfoCode = "others";
                        }
                        detail.transState = detail.payInfoCode;
                    }else {
                        detail.respCode = "-1";
                        detail.respInfo = "银行返回的数据格式不符合预期";
                    }
                }else {
                    detail.respCode = "-1";
                    detail.respInfo = tmpStrRet[1].toString();
                }
            }catch(Exception e){
                e.printStackTrace();
                WriteBankLogLn("票据"+query.detail.billNo+"质押申请异常");
            }finally {
                conn.close();
            }
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 提示付款 b2e0111 已测

     */
    @Override
    public RetAtsB108BillPaySubmit D_B108_BillResp_Submit(ReqB108BillPaySubmit query) throws Exception{
        RetAtsB108BillPaySubmit retAts=new RetAtsB108BillPaySubmit(query.reqHeader);
        RetAtsB108BillPaySubmitDetail detail=new RetAtsB108BillPaySubmitDetail();
        retAts.writeBeforeDetail();
        Connection conn= FGBiz.getLocalDbConn();
        while(query.readRecord()){
            try{
                StringBuilder stringBuilder=new StringBuilder();
                for(int i=0;i<11;i++){
                    stringBuilder.append("{"+i+"}#");
                }
                stringBuilder.append("@@@@");
                String[] body=new String[11];
                body[0]="B305001";//交易代码
                body[1]=query.detail.billNo;//电子票据号码
                String bankSeqId=getQryTransID2();
                body[2]=bankSeqId;//业务参考号
                String uuid = UUID.randomUUID().toString().replaceAll("-", "");
                JDBCHelper.update(conn, INSERTSEQ, new Object[]{uuid, query.reqHeader.bankCode, Format.Date8Format.format(new Date()), query.detail.reqSeqID, bankSeqId});
                body[3]= "1".equals(query.detail.proPayType)?"0":"1";//提示付款种
                body[4]=com.fingard.constant.Format.Date10Format.format(new Date());//提示付款申请日期
                body[5]=query.detail.overDueRea;//逾期原因说明
                body[6]="1".equals(query.detail.payType)?"SM00":"SM01";//线上清算标记
                body[7]="";//网银客户号
                body[8]="";//电子签名
                body[9]=query.detail.actNum;//帐号
                body[10]=query.detail.memo;//备注
                String sendInfo = MessageFormat.format(stringBuilder.toString(),body[0],body[1],body[2],body[3],body[4],body[5],
                        body[6],body[7],body[8],body[9],body[10]);
                //请求银行
                String[] tmpStrRet = sendToBank(sendInfo);
                if (tmpStrRet[0].length() == 0) {
                    //返回码
                    String[] resultArr = tmpStrRet[1].trim().replaceAll("@","").replaceAll("\r","")
                            .replaceAll("\n","").split("#");
                    if (!StringHelper.isNullOrEmpty(resultArr[0])) {
                        detail.respCode = "0";
                        detail.respInfo = "";
                        detail.reqSeqID = query.detail.reqSeqID;
                        if("000000".equals(resultArr[0].trim()) || "111111".equals(resultArr[0].trim()) || "EL6001".equals(resultArr[0].trim())){
                            detail.payInfoCode = resultArr[0];
                        }else {
                            detail.payInfoCode = "others";
                        }
                        detail.transState = detail.payInfoCode;
                    }else {
                        detail.respCode = "-1";
                        detail.respInfo = "银行返回的数据格式不符合预期";
                    }
                }else {
                    detail.respCode = "-1";
                    detail.respInfo = tmpStrRet[1].toString();
                }
            }catch(Exception e){
                e.printStackTrace();
                WriteBankLogLn("票据"+query.detail.billNo+"提示付款异常");
            }finally {
                conn.close();
            }
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 保证申请  b2e0281 未测，暂无此业务

     */
    @Override
    public RetAtsB109BillGuarSubmit D_B109_BillResp_Submit(ReqB109BillGuarSubmit query) throws Exception{
        RetAtsB109BillGuarSubmit retAts=new RetAtsB109BillGuarSubmit(query.reqHeader);
        RetAtsB109BillGuarSubmitDetail detail=new RetAtsB109BillGuarSubmitDetail();
        retAts.writeBeforeDetail();
        while(query.readRecord()){
            try{
                StringBuilder stringBuilder=new StringBuilder();
                for(int i=0;i<9;i++){
                    stringBuilder.append("{"+i+"}#");
                }
                stringBuilder.append("@@@@");
                String[] body=new String[9];
                body[0]="B309001";//交易代码
                body[1]=query.detail.billNo;//票据号码
                //被保证人信息
                body[2]="";//网银客户号
                body[3]="";//电子签名
                body[4]=query.detail.actNum;//帐号
                //保证人信息
                body[5]=query.detail.receName;//名称
                body[6]=query.detail.receAct;//账号
                body[7]=query.detail.receBnkCode;//开户行行号
                body[8]=query.detail.memo;//备注
                String sendInfo = MessageFormat.format(stringBuilder.toString(),body[0],body[1],body[2],body[3],
                        body[4],body[5],body[6],body[7],body[8]);
                //请求银行
                String[] tmpStrRet = sendToBank(sendInfo);
                if (tmpStrRet[0].length() == 0) {
                    //返回码
                    String[] resultArr = tmpStrRet[1].trim().replaceAll("@","").replaceAll("\r","")
                            .replaceAll("\n","").split("#");
                    if (!StringHelper.isNullOrEmpty(resultArr[0])) {
                        detail.respCode = "0";
                        detail.respInfo = "";
                        detail.reqSeqID = query.detail.reqSeqID;
                        if("000000".equals(resultArr[0].trim()) || "111111".equals(resultArr[0].trim()) || "EL6001".equals(resultArr[0].trim())){
                            detail.payInfoCode = resultArr[0];
                        }else {
                            detail.payInfoCode = "others";
                        }
                        detail.transState = detail.payInfoCode;
                    }else {
                        detail.respCode = "-1";
                        detail.respInfo = "银行返回的数据格式不符合预期";
                    }
                }else {
                    detail.respCode = "-1";
                    detail.respInfo = tmpStrRet[1].toString();
                }
            }catch(Exception e) {
                e.printStackTrace();
                WriteBankLogLn("票据" + query.detail.billNo + "保证申请异常");
            }
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 追索通知 b2e0282 未测，银企直联不支持
     */
    @Override
    public RetAtsB110BillRecoSubmit D_B110_BillResp_Submit(ReqB110BillRecoSubmit query) throws Exception{
        RetAtsB110BillRecoSubmit retAts=new RetAtsB110BillRecoSubmit(query.reqHeader);
        RetAtsB110BillRecoSubmitDetail detail=new RetAtsB110BillRecoSubmitDetail();
        retAts.writeBeforeDetail();
        while(query.readRecord()){
            try{
                StringBuilder stringBuilder=new StringBuilder();
                for(int i=0;i<12;i++){
                    stringBuilder.append("{"+i+"}#");
                }
                stringBuilder.append("@@@@");
                String[] body=new String[12];
                body[0]="B206001";//交易代码
                body[1]=query.detail.billNo;//票据号码
                //追索通知信息
                body[2]="1".equals(query.detail.recourseType)?"RT00":"RT01";//追索类型
                body[3]=Format.Date10Format.format(new Date());//追索通知日期
                //追索人信息
                body[4]=bankFront.corpNo;//网银客户号
                body[5]="";//电子签名
                body[6]=query.detail.actNum;//账号
                body[7]=query.detail.memo;//备注
                body[8]="1";//数量
                //被追索人信息
                body[9]=query.detail.recourseAmt.contains(".")?query.detail.recourseAmt:query.detail.recourseAmt+".00";//追索金额
                body[10]=query.detail.receAct;//账号
                body[11]=query.detail.receBnkCode;//开户行行号

                String sendInfo = MessageFormat.format(stringBuilder.toString(),body[0],body[1],body[2],body[3],
                        body[4],body[5],body[6],body[7],body[8],body[9],body[10],body[11]);
                //请求银行
                String[] tmpStrRet = sendToBank(sendInfo);
                if (tmpStrRet[0].length() == 0) {
                    //返回码
                    String[] resultArr = tmpStrRet[1].trim().replaceAll("@","").replaceAll("\r","")
                            .replaceAll("\n","").split("#");
                    if (!StringHelper.isNullOrEmpty(resultArr[0])) {
                        detail.respCode = "0";
                        detail.respInfo = "";
                        detail.reqSeqID = query.detail.reqSeqID;
                        if("000000".equals(resultArr[0].trim()) || "111111".equals(resultArr[0].trim()) || "EL6001".equals(resultArr[0].trim())){
                            detail.payInfoCode = resultArr[0];
                        }else {
                            detail.payInfoCode = "others";
                        }
                        detail.transState = detail.payInfoCode;
                    }else {
                        detail.respCode = "-1";
                        detail.respInfo = "银行返回的数据格式不符合预期";
                    }
                }else {
                    detail.respCode = "-1";
                    detail.respInfo = tmpStrRet[1].toString();
                }
            }catch(Exception e){
                e.printStackTrace();
                WriteBankLogLn("票据"+query.detail.billNo+"追索异常");
            }
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 同意清偿 b2e0112  未测，银企直联不支持

     */
    @Override
    public RetAtsB111BillAgreeSubmit D_B111_BillResp_Submit(ReqB111BillAgreeSubmit query) throws Exception{
        RetAtsB111BillAgreeSubmit retAts=new RetAtsB111BillAgreeSubmit(query.reqHeader);
        RetAtsB111BillAgreeSubmitDetail detail=new RetAtsB111BillAgreeSubmitDetail();
        retAts.writeBeforeDetail();
        while(query.readRecord()){
            try{
                StringBuilder stringBuilder=new StringBuilder();
                for(int i=0;i<8;i++){
                    stringBuilder.append("{"+i+"}#");
                }
                stringBuilder.append("@@@@");
                String[] body=new String[8];
                body[0]="B207001";//交易代码
                body[1]=query.detail.billNo;//票据号码
                //同意清偿信息
                body[2]=Format.Date10Format.format(new Date());//同意清偿日期
                body[3]=query.detail.agreeAmt;//同意清偿金额
                //同意清偿人信息（被追索人之一）
                body[4]=bankFront.corpNo;//网银客户号
                body[5]="";//电子签名
                body[6]=query.detail.actNum;//账号
                body[7]=query.detail.memo;//备注
                String sendInfo = MessageFormat.format(stringBuilder.toString(),body[0],body[1],body[2],body[3],body[4],body[5],body[6],body[7]);
                //请求银行
                String[] tmpStrRet = sendToBank(sendInfo);
                if (tmpStrRet[0].length() == 0) {
                    //返回码
                    String[] resultArr = tmpStrRet[1].trim().replaceAll("@","").replaceAll("\r","")
                            .replaceAll("\n","").split("#");
                    if (!StringHelper.isNullOrEmpty(resultArr[0])) {
                        detail.respCode = "0";
                        detail.respInfo = "";
                        detail.reqSeqID = query.detail.reqSeqID;
                        if("000000".equals(resultArr[0].trim()) || "111111".equals(resultArr[0].trim()) || "EL6001".equals(resultArr[0].trim())){
                            detail.payInfoCode = resultArr[0];
                        }else {
                            detail.payInfoCode = "others";
                        }
                        detail.transState = detail.payInfoCode;
                    }else {
                        detail.respCode = "-1";
                        detail.respInfo = "银行返回的数据格式不符合预期";
                    }
                }else {
                    detail.respCode = "-1";
                    detail.respInfo = tmpStrRet[1].toString();
                }
            }catch(Exception e) {
                e.printStackTrace();
                WriteBankLogLn("票据" + query.detail.billNo + "同意清偿异常");
            }
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    /**
     * 交易撤回 b2e0106  已测，但是原业务流水号oldSeq传送空？
     */
    @Override
    public RetAtsB112BillCancSubmit D_B112_BillResp_Submit(ReqB112BillCancSubmit query) throws Exception{
        RetAtsB112BillCancSubmit retAts=new RetAtsB112BillCancSubmit(query.reqHeader);
        RetAtsB112BillCancSubmitDetail detail=new RetAtsB112BillCancSubmitDetail();
        retAts.writeBeforeDetail();
        Connection conn= FGBiz.getLocalDbConn();
        while(query.readRecord()){
            try{
                StringBuilder stringBuilder=new StringBuilder();
                for(int i=0;i<10;i++){
                    stringBuilder.append("{"+i+"}#");
                }
                stringBuilder.append("@@@@");
                String[] body=new String[10];
                body[0]="B309002";//交易代码
                body[1]="";//批次号
                String seqNo="";//业务流水号
                Map<String, Object> selMap= JDBCHelper.execQuerySingle(conn,SELECTSEQ,new Object[]{query.detail.oldSeq});
                if(selMap.size()>0){
                    seqNo=selMap.get("BANKREQSEQID").toString();
                }else {
                    retAts.writeRespCode("-1");
                    retAts.writeRespInfo("业务流水号关联异常");
                    retAts.writeEnd();
                    return retAts;
                }
                body[2]=seqNo;//原申请业务参考号
                String bankSeqId=getQryTransID2();
                body[3]=bankSeqId;//业务参考号
                String uuid = UUID.randomUUID().toString().replaceAll("-", "");
                JDBCHelper.update(conn, INSERTSEQ, new Object[]{uuid, query.reqHeader.bankCode, Format.Date8Format.format(new Date()), query.detail.reqSeqID, bankSeqId});
                body[4]=query.detail.billNo;
                body[5]=query.detail.billAmt.contains(".")?query.detail.billAmt:query.detail.billAmt+".00";//票面金额
                //根据票据编号查询票据状态：因ats未返回票据类型，暂时只查银票
                String[] status=new String[2];
                for(int i=0;i<4;i++){
                    status=getBillStatus(query.detail.billNo,getBankConfig().getMapKeyByValue("billTypeMapping","1"),query.detail.actNum,i+"");
                    if(com.fingard.text.StringHelper.hasAnyChar(status[0])){
                        break;
                    }
                }
                if(com.fingard.text.StringHelper.hasAnyChar(status[0])){
                    if(billStatus(query.detail.cancelType,status[1])){
                        body[6]=status[1];//票据状态
                        body[7]="";//申请人客户号
                        body[8]=query.detail.actNum;//申请人客户账号
                        body[9]="";//申请人电子签名
                        String sendInfo = MessageFormat.format(stringBuilder.toString(),body[0],body[1],body[2],body[3],body[4],body[5],body[6],body[7],body[8],body[9]);
                        //请求银行
                        String[] tmpStrRet = sendToBank(sendInfo);
                        if (tmpStrRet[0].length() == 0) {
                            //返回码
                            String[] resultArr = tmpStrRet[1].trim().replaceAll("@","").replaceAll("\r","")
                                    .replaceAll("\n","").split("#");
                            if (!StringHelper.isNullOrEmpty(resultArr[0])) {
                                detail.respCode = "0";
                                detail.respInfo = "";
                                detail.reqSeqID = query.detail.reqSeqID;
                                if("000000".equals(resultArr[0].trim()) || "111111".equals(resultArr[0].trim()) || "EL6001".equals(resultArr[0].trim())){
                                    detail.payInfoCode = resultArr[0];
                                }else {
                                    detail.payInfoCode = "others";
                                }
                                detail.transState = detail.payInfoCode;
                            }else {
                                detail.respCode = "-1";
                                detail.respInfo = "银行返回的数据格式不符合预期";
                            }
                        }else {
                            detail.respCode = "-1";
                            detail.respInfo = tmpStrRet[1].toString();
                        }
                    }else {
                        detail.respCode="-1";
                        detail.respInfo="撤回类型和票据类型不对应";
                    }
                }else {
                    detail.respCode = "-1";
                    detail.respInfo ="查询票据状态或背书转让标识异常";
                }
            }catch(Exception e){
                e.printStackTrace();
                WriteBankLogLn("票据"+query.detail.billNo+"交易撤回异常");
            }finally {
                conn.close();
            }
        }
        retAts.writeDetail(detail);
        retAts.writeEnd();
        return retAts;
    }

    @Override
    public RetAtsB113ProtocolSubmit D_B113_ProtocolResp_Submit(ReqB113ProtocolSubmit query) throws Exception {
        return null;
    }

    @Override
    public RetAtsB119BillRelePledSubmit D_B119_BillResp_Submit(ReqB119BillRelePledSubmit query) throws Exception {
        return null;
    }
}
